package com.lmaye.design.patterns.ood.lsp.example;

import java.math.BigDecimal;

/**
 * -- Bird
 *
 * @author lmay.Zhou
 * @date 2020/11/12 19:57 星期四
 * @qq 379839355
 * @email lmay@lmaye.com
 * @since JDK1.8
 */
public abstract class Bird {
    /**
     * 飞行速度
     */
    protected double flySpeed;

    /**
     * 获取飞行时间
     *
     * @param distance 距离
     * @return double
     */
    public double getFlyTime(double distance) {
        if(0.0 == flySpeed) {
            return 0.0;
        }
        return new BigDecimal(distance / flySpeed).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
    }

    public void setFlySpeed(double flySpeed) {
        this.flySpeed = flySpeed;
    }
}
